<template>
  <div>
    <el-card>
      <div>
        题目名称:<el-input v-model="queryInfo.input" placeholder="请输入内容" clearable @input="change" @clear="clear" />
        <!-- 审核状态:<el-select v-model="queryInfo.status" placeholder="请选择" @change="change">
          <el-option
            v-for="item in options"
            :key="item.value"
            :label="item.label"
            :value="item.value"
            :selected="item.label=='全部' ? true : false"
          />
        </el-select> -->
      </div>
      <el-table
        :data="shentable"
        style="width: 100%"
      >
        <el-table-column
          label="序号"
          type="index"
          width="130px"
        />
        <el-table-column
          label="题目"
          prop="title"
        />
        <el-table-column
          label="类别"
        >
          <template slot-scope="scope">
            {{ scope.row.cata_o.cateName }}
          </template>
        </el-table-column>
        <el-table-column
          label="上传者"
          prop="uploder"
        />
        <el-table-column
          label="上传状态"
        >
          <template slot-scope="scope">
            <span v-if="scope.row.status==1">已发布</span>
            <span v-if="scope.row.status==0">提交(待审核)</span>
            <span v-if="scope.row.status==2">未通过审核</span>
          </template>
        </el-table-column>
        <el-table-column label="操作" width="200px">
          <template slot-scope="scope">
            <el-button @click="xq(scope.row)"><a class="blue">详情</a></el-button>
          </template>
        </el-table-column>
      </el-table>

      <el-pagination
        :page-sizes="[5, 10, 15, 20]"
        :page-size="5"
        layout="total, sizes, prev, pager, next, jumper"
        :total="queryInfo.t"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
      />
    </el-card>
  </div>
</template>

<script>
export default {
  components: {},
  props: {},
  data() {
    return {
      shentable: [],
      form: {
        id: '',
        reason: ''
      },
      queryInfo: {
        input: '',
        size: 5,
        page: 1,
        t: 0,
        status: '',
        wei:1
      },
      dialogFormVisible: false,
      options: [{
        value: 3,
        label: '全部'
      }, {
        value: 0,
        label: '待审核'
      }, {
        value: 1,
        label: '已发布'
      }, {
        value: 2,
        label: '未通过'
      }],

      pageisornot: false,
      rules: {
        reason: [
          { required: true, message: '请输入驳回理由', trigger: 'blur' }
        ]
      }
    }
  },
  computed: {},
  watch: {},
  created() {
    this.getqst()
  },
  mounted() {},
  methods: {

    async getqst() {
      var res = await this.http.get('/knowledge/ques/', { params: this.queryInfo })

      console.log(res, '222222132')
      // 待审核的列表
      var L=[]
      res.data.data.forEach(item=>{
          if (item.status==0){
            L.push(item)
          }
      })
      console.log(L,'dd');
      //   var res=await this.http.get('/cateall')
      if (res.data.code == 200) {
        // this.tableData = res.data.data1
        this.shentable =L
        this.queryInfo.t = L.length
      }

      //   this.pageisornot=false
      // var res=await this.http.get('/question',{
      //   params:{
      //       page:this.page,
      //       size:this.size
      //   }
      // })
      // if(res.data.code == 200){
      //     this.shentable = res.data.data
      //     this.t=res.data.total
      // }
    },
    xq(row) {
      this.$router.push({ path: '/xq', query: { id: row.id ,info:'题目审核'}})
    },
    async change() {
    // if(!this.pageisornot){
    //     this.page=1
    // }
    // if(this.status!=3 ){
    //     var res=await this.http.get('/question',{
    //         params:{
    //             status:this.status,
    //             page:this.page,
    //             size:this.size,
    //             title:this.input
    //         }
    //     })
    //     if(res.data.code==200){
    //         this.shentable=res.data.data
    //         this.t=res.data.total
    //     }
    // }else{
      this.getqst()
    // }
    // this.pageisornot=true
    },
    clear() {

    },
    handleSizeChange(v) {
      this.queryInfo.size = v
      this.getqst()
      // if(this.pageisornot){
      //     this.change()
      // }else{
      //     this.getqst()
      // }
    },
    handleCurrentChange(v) {
      this.queryInfo.page = v
      this.getqst()
      // if(this.pageisornot){
      //     this.change()
      // }else{
      //     this.getqst()
      // }
    }
  }
}
</script>
<style scoped>
    .el-input{
        width: 200px;
        margin-left: 7px;
    }
    .el-select{
        margin-left: 7px;
    }
    .el-pagination{
      margin-top: 20px;
      text-align: center;
    }
    .el-table .el-button{
      background: 0;
      padding-left: 0;
      padding-right: 0;
      display: inline-block;
      border:0;
    }
    .green{
      color: green;
    }
    .blue{
      color: #3175fb;
    }
    .red{
      color: red;
    }
    .qgreen{
      color: #c4e2d6;
    }
    .qred{
      color: #f6caca;
    }
</style>
